<html>
<head><meta charset="utf-8"><title>Mark some lints as only usable at crate level · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Mark.20some.20lints.20as.20only.20usable.20at.20crate.20level.html">Mark some lints as only usable at crate level</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="197035575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Mark%20some%20lints%20as%20only%20usable%20at%20crate%20level/near/197035575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Mark.20some.20lints.20as.20only.20usable.20at.20crate.20level.html#197035575">(May 10 2020 at 05:50)</a>:</h4>
<p>What's the proper way to mark some lints as only usable at crate level? I want to emit a warning or an error when user attempts to tune its level at finer grained level.</p>



<a name="197123333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Mark%20some%20lints%20as%20only%20usable%20at%20crate%20level/near/197123333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Mark.20some.20lints.20as.20only.20usable.20at.20crate.20level.html#197123333">(May 11 2020 at 10:02)</a>:</h4>
<p>you can use <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/trait.LateLintPass.html#method.enter_lint_attrs">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/trait.LateLintPass.html#method.enter_lint_attrs</a> to error on specific attributes. You'll need to store a flag in your lint pass struct so you don't lint on the crate attributes and then change that flag in <code>check_crate</code> at which point the first <code>enter_lint_attrs</code> will already have been called</p>



<a name="197179102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Mark%20some%20lints%20as%20only%20usable%20at%20crate%20level/near/197179102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Mark.20some.20lints.20as.20only.20usable.20at.20crate.20level.html#197179102">(May 11 2020 at 17:34)</a>:</h4>
<p>Thanks!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>